package com.zhaowt.dto;

import com.zhaowt.exception.MyErrorCode;

/**
 * created by 赵文韬 on 2022/12/24 23:05
 */
public class R {
    private int code;
    private String msg;
    private Object data;
    public static R setOk(){
        return setOk(null);
    }
    public static R setError(){
        return setError(null);
    }

    public static R setOk(Object data){
        return getR(MyErrorCode.SUCCESS, "成功",data );
    }

    public static  R setError(Object data){
        return getR(MyErrorCode.FAIL,"失败" ,data );

    }



    public static  R getR(int code,String msg,Object data){
        R r = new R();
        r.setCode(code);
        r.setData(data);
        r.setMsg(msg);
        return r;
    }

    public R() {
    }

    public R(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
